<template>
  <div
    style="
      margin: 20px 0;
      font-size: 16px;
      font-weight: bold;
      color: #333;
      text-align: center;
      padding: 10px;
      background-color: #f9f9f9;
      border: 1px solid #ddd;
      border-radius: 5px;
    "
  >
    预算采购：{{ totalBudget }}
  </div>
</template>

<script>
export default {
  name: "SumData",
  props: {
    vendorAddList: {
      type: Array,
      default: () => [],
    },
    ECommerceAddList: {
      type: Array,
      default: () => [],
    },
    sporadicAddList: {
      type: Array,
      default: () => [],
    },
    otherAddList: {
      type: Array,
      default: () => [],
    },
  },
  computed: {
    totalBudget() {
      // 累加四个数组的 totalBudget 字段
      const lists = [
        this.vendorAddList,
        this.ECommerceAddList,
        this.sporadicAddList,
        this.otherAddList,
      ];
      let total = 0;
      lists.forEach(list => {
        list.forEach(item => {
          total += parseFloat(item.totalBudget) || 0;
        });
      });
      return total ? total.toFixed(2) : "暂无";
    },
  },
};
</script>
